#pragma once
#include <string>
#include <netinet/in.h>
#include <arpa/inet.h>

class Int_Addr
{
private:
    void ToHost()
    {
        // 将网络序列转为本机序列
        _ip = inet_ntoa(_addr.sin_addr);
        _port = ntohs(_addr.sin_port);
    }

public:
    Int_Addr(const struct sockaddr_in &peer)
        : _addr(peer)
    {
        ToHost();
    }

    std::string Ip()
    {
        return _ip;
    }

    uint16_t Port()
    {
        return _port;
    }

    ~Int_Addr()
    {
    }

private:
    std::string _ip;
    uint16_t _port;
    struct sockaddr_in _addr;
};